package com.atguigu.tingshu.model.search;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.CompletionField;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.core.suggest.Completion;

@Data
@Document(indexName = "suggestinfo")  //一个建议词文档对应索引库名称
@JsonIgnoreProperties(ignoreUnknown = true)//目的：防止json字符串转成实体对象时因未识别字段报错
public class SuggestIndex {


    /**
     * 提词文档唯一标识
     */
    @Id
    private String id;

    /*
    * 原始内容：经典留声机
    *
    * */

    /**
     *
     * 存放 专辑标题 或者 主播名称 原始内容
     * 采用标准分词器：将一个汉拆为一个词
     * ES内部字段拆分：经 典 留 声 机
     */
    @Field(type = FieldType.Text, analyzer = "standard")
    private String title;

    /*
        建议词字段一：ES内部字段拆分：经 典 留 声 机
    * */
    @CompletionField(analyzer = "standard", searchAnalyzer = "standard", maxInputLength = 20)
    private Completion keyword;

    /*
        建议词字段二：
        ES内部字段拆分：jingdianliushengji
    * */
    @CompletionField(analyzer = "standard", searchAnalyzer = "standard", maxInputLength = 20)
    private Completion keywordPinyin;

    /*
       建议词字段三：
       ES内部字段拆分：jdlsj
   * */
    @CompletionField(analyzer = "standard", searchAnalyzer = "standard", maxInputLength = 20)
    private Completion keywordSequence;

}
